<?php 
session_start();
require_once('functions.php');
if($_SESSION['loggedIn'] != true) {redirect_php('login.php'); die;}
?>
<!DOCTYPE html>
<html>
	<title>Чары сгенерированы</title>
<?php require_once('head.php');  ?>
<?php require_once('menu.php');  ?>
    <link rel="stylesheet" href="http://yandex.st/highlightjs/8.0/styles/monokai_sublime.min.css">
    <script src="http://yandex.st/highlightjs/8.0/highlight.min.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>

<body>
	

<?php
require_once('functions.php');
$totalInsertQuerys = 0;
$totalDeleteQuerys = 0;
$xml = '';
    $query = "SELECT * FROM aa_clear_accounts";
    $result = mysql_query($query) or die("error 33");
    for ($c=0; $c < count($_POST['data']); $c++)
    {
        if ((int)($_POST['data'][$c]) == "0"){continue;}      // $_POST['data'][$c] - КОЛИЧЕСТВО ЗАПИСЕЙ   $c - сервак
        else
        {
            for ($i = 0 ; $i < ($_POST['data'][$c]) ; $i++)
            {
                $t = mysql_fetch_row($result);
                if (!$t) {echo "<div class='bg-danger' style='padding: 10px;' ><h1>Закончились чистые аккаунты</h1></div>"; break;}
                $pizdec = mysql_fetch_row( mysql_query("SELECT * FROM `nicks` ORDER BY RAND() LIMIT 0,1;"));
                $botName = $pizdec[1];
                $HWID = randomDString('9');
                $port = getVacantPort();
                $insertQuery = "INSERT INTO `accounts`
                (  `charname`, `server`,  `login`, `password` , `port`)
                VALUES
                (  '".$botName."' , (SELECT server FROM `aa_warehouses`  WHERE id = ".$c." LIMIT 1), '$t[1]', '$t[2]' , ".$port.");";
                var_dump($insertQuery);
                $deleteQuery = "DELETE FROM `aa_clear_accounts` WHERE `id` = ".$t[0];
                $totalInsertQuerys+=  $res = mysql_query($insertQuery) or die("error 33");  echo "...<br>";
                $totalDeleteQuerys+=  $res2 = mysql_query($deleteQuery) or die("error 33"); echo "...<br>";
                $xml .= '<Num_0 Marked="true" Name="'.$botName.'" Login="'.$t[1].'" Passw="'.$t[2].'" Server="'.$c.'" UID="" HWID="'.$HWID.'" Proxy="1" ProxyIP="5.105.140.144" ProxyPort="'.$port.'" ProxyUser="venge" ProxyPass="antikiller14" Script="" UserName="'.$botName.'" Level="0" PremiumTime="0" Exp="0" Gold="0" IsBanned="false" AEETime="0" RJB="0" Class="0" CharIndex="0" NewClass="0"/>
';
            } // for 2
        }    // else

    }  // for 1

            if ($xml)
        {
            echo "<pre>
            Записей вставлено: $totalInsertQuerys
            Записей удалено: $totalDeleteQuerys

            <code>";
            echo htmlspecialchars($xml);
            echo "</code></pre>";
        }


?>

</body>
<html>

